package com.zimmur.service.impl.zone;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zimmur.common.AppModuleEnum;
import com.zimmur.dao.zone.ITopicFavDao;
import com.zimmur.model.account.view.ConcernView;
import com.zimmur.model.base.AdBanner;
import com.zimmur.model.desiger.view.DesigerInfoVo;
import com.zimmur.model.zone.TopicFav;
import com.zimmur.model.zone.view.ConcernUserView;
import com.zimmur.service.base.IAdBannerService;
import com.zimmur.service.zone.ITopicFavService;
import com.zimmur.tools.PageUtil;

@Service("topicFavService")  
public class TopicFavServiceImpl implements ITopicFavService{
	@Resource
	private ITopicFavDao topicFavDao;
	@Resource
	private IAdBannerService adBannerService;
	
	public TopicFav selectTopicFav(long createUserId, long userId) {
		
		return topicFavDao.selectTopicFav(createUserId, userId);
	}

	@Override
	public int updateTopicFav(TopicFav topicFav) {
		
		return topicFavDao.updateTopicFav(topicFav);
	}

	@Override
	public int insertTopicFav(TopicFav topicFav) {
		
		return topicFavDao.insertTopicFav(topicFav);
	}

	@Override
	public int countByCreateUserId(long createUserId,Integer userType) {
		
		return topicFavDao.countTopicFavByCreateUserId(createUserId,userType);
	}
	
	@Override
	public ConcernUserView selectConcernUserIndex(long createUserId) {
		ConcernUserView concernUserView=new ConcernUserView();
		
		PageUtil<ConcernView> hotUserList=selectConcernUserByTopicFav(createUserId, 1, 1);
		PageUtil<ConcernView> drUserList=selectConcernUserByTopicFav(createUserId, 1, 2);
		PageUtil<ConcernView> xkUserList=selectConcernUserByTopicFav(createUserId, 1, 3);
		concernUserView.setHotUserList(hotUserList);
		concernUserView.setDrUserList(drUserList);
		concernUserView.setXkUserList(xkUserList);
		
		return concernUserView;
	}

	@Override
	public PageUtil<ConcernView> selectConcernUserByTopicFav(long createUserId, int pageNo, Integer userType) {
			PageUtil<ConcernView> page=new PageUtil<>();
					
			if(pageNo==0){
				pageNo=1;
			}
			
			int totalRecord=countByCreateUserId(createUserId,userType);
			page.setTotalRecord(totalRecord);
			page.setPageNo(pageNo);
			if(totalRecord>0){
				List<ConcernView> concernViews=topicFavDao.selectUserByTopicFav(createUserId, page.getPageBeginNo(), page.getPageSize(), userType);
				page.setItemList(concernViews);
			}
			return page;
	}

}
